package com.test.clyq.serviceImpl;

import java.util.List;

import com.test.clyq.dao.CategoryDao;
import com.test.clyq.entity.Category;
import com.test.clyq.entity.Users;
import com.test.clyq.service.CategoryService;
import com.test.service.impl.BaseManager;
import com.test.util.Pagination;

/**
 * CategoryServiceImpl. <br>
 * 栏目信息管理.
 * <p>
 * Copyright: Copyright (c) 2010-4-18 下午02:44:13
 * <p>
 * Company: 北京宽连十方数字技术有限公司
 * <p>
 * Author: liuxl@c-platform.com
 * <p>
 * Version: 1.0
 * <p>
 */
@SuppressWarnings("unchecked")
public class CategoryServiceImpl extends BaseManager implements CategoryService {

	private CategoryDao categoryDao;

	public void addCategory(Category category, Users user) {
		this.categoryDao.addCategory(category, user);
	}

	public List<Category> categoryList(Pagination pagination) {
		return this.categoryDao.categoryList(pagination);
	}

	public boolean delCategoryById(Long id, Users user) {
		return this.categoryDao.delCategoryById(id, user);
	}

	public Category getCategoryById(Long id) {
		return this.categoryDao.getCategoryById(id);
	}

	public List<Category> getCategoryListAllByParentId(Long parentId) {
		return this.categoryDao.getCategoryListAllByParentId(parentId);
	}

	public List<Category> getCategoryListByParentId(Long parentId) {
		return this.categoryDao.getCategoryListByParentId(parentId);
	}

	/**
	 * 获得父栏目下属的所有子栏目列表
	 * 
	 * @param id
	 *            parentId
	 * @return 栏目信息列表结果集合
	 */
	public List<Category> getCategoryListByParentId(Long parentId, String isPublic, String type) {
		return this.categoryDao.getCategoryListByParentId(parentId, isPublic, type);
	}

	public List<Category> getCategorys() {
		return this.categoryDao.getCategorys();
	}

	@Override
	public List<Category> getCategorys(Integer website) {
		return this.categoryDao.getCategorys(website);
	}

	@Override
	public List<Category> getFirstLevelCategoryList(Integer website, Pagination pagination) {
		return this.categoryDao.getFirstLevelCategoryList(website, pagination);
	}

	public List<Category> getFirstLevelCategoryList(Pagination pagination) {
		return this.categoryDao.getFirstLevelCategoryList(pagination);
	}

	public List<Category> getPublicCategorys() {
		return this.categoryDao.getPublicCategorys();
	}

	public List<Category> getTreeList(Long id) {
		return this.categoryDao.getTreeList(id);
	}

	public void saveOrUpdate(Category category, Users user) {
		this.categoryDao.saveOrUpdate(category, user);
	}

	public void setCategoryDao(CategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}
}
